package com.example.week9_spring_aop.apis.impl;

import com.example.week9_spring_aop.apis.ApiForTest;
import com.example.week9_spring_aop.exception.TestException;
import org.springframework.stereotype.Component;

import java.util.Random;

import static java.lang.Thread.sleep;

@Component
public class ApiForTestImpl implements ApiForTest {

    @Override
    public void TestApi(RunMode runMode, Long sleepTime) throws InterruptedException, TestException {
        sleep(sleepTime);
        if (runMode == RunMode.Exception) {
            throw new TestException("Test exception");
        }
    }
}